home *** CD-ROM | disk | FTP | other *** search
- unit CompMenu;
- interface
- uses
- DsgnIntf;
-
- Type
- TCommonDialogComponentEditor = class(TComponentEditor)
- function GetVerbCount: Integer; override;
- function GetVerb(index: Integer): String; override;
- procedure Executeverb(index: Integer); override;
- end;
-
- TCommonDialogDefaultEditor = class(TDefaultEditor)
- function GetVerbCount: Integer; override;
- function GetVerb(index: Integer): String; override;
- procedure Executeverb(index: Integer); override;
- end;
-
- procedure Register;
-
- implementation
- uses
- Dialogs;
-
- { TCommonDialogComponentEditor }
-
- function TCommonDialogComponentEditor.GetVerbCount: Integer;
- begin
- GetVerbCount := 2
- end {GetVerbCount};
-
- function TCommonDialogComponentEditor.GetVerb(index : Integer): String;
- begin
- if Index >= 1 then GetVerb := '&About...'
- else GetVerb := '&Execute ' + Component.ClassName + '...'
- end {GetVerb};
-
- procedure TCommonDialogComponentEditor.ExecuteVerb(index: Integer);
- begin
- if index >= 1 then
- MessageDlg('TCommonDialogComponentEditor (c) 1996 by Dr.Bob#13for The Delphi Magazine',
- mtInformation, [mbOk], 0)
- else
- begin
- if (Component IS TOpenDialog) then { also TSaveDialog }
- (Component AS TOpenDialog).Execute
- else
- if (Component IS TPrintDialog) then
- (Component AS TPrintDialog).Execute
- else
- if (Component IS TPrinterSetupDialog) then
- (Component AS TPrinterSetupDialog).Execute
- else
- if (Component IS TColorDialog) then
- (Component AS TColorDialog).Execute;
- Designer.Modified
- end
- end {ExecuteVerb};
-
- { TCommonDialogDefaultEditor }
-
- function TCommonDialogDefaultEditor.GetVerbCount: Integer;
- begin
- GetVerbCount := 3
- end {GetVerbCount};
-
- function TCommonDialogDefaultEditor.GetVerb(index : Integer): String;
- begin
- case Index of
- 0: GetVerb := '&OnEvent handler code';
- 1: GetVerb := '&Execute ' + Component.ClassName + '...';
- else GetVerb := '&About...'
- end
- end {GetVerb};
-
- procedure TCommonDialogDefaultEditor.ExecuteVerb(index: Integer);
- begin
- if index >= 2 then
- MessageDlg('TCommonDialogDefaultEditor (c) 1996 by Dr.Bob#13for The Delphi Magazine',
- mtInformation, [mbOk], 0)
- else
- if index = 1 then
- begin
- if (Component IS TFindDialog) then { also TReplaceDialog }
- (Component AS TFindDialog).Execute
- else
- if (Component IS TFontDialog) then
- (Component AS TFontDialog).Execute;
- Designer.Modified
- end
- else inherited Edit { TDefaultEditor.Edit }
- end {ExecuteVerb};
-
- procedure Register;
- begin
- { empty default component editors }
- RegisterComponentEditor(TOpenDialog, TCommonDialogComponentEditor);
- RegisterComponentEditor(TPrintDialog, TCommonDialogComponentEditor);
- RegisterComponentEditor(TPrinterSetupDialog, TCommonDialogComponentEditor);
- RegisterComponentEditor(TColorDialog, TCommonDialogComponentEditor);
- { event default component editors }
- RegisterComponentEditor(TFontDialog, TCommonDialogDefaultEditor);
- RegisterComponentEditor(TFindDialog, TCommonDialogDefaultEditor)
- end;
- end.
-